package design_pattern.SingleThreadExecute;

/**
 * @Author: 蔡翔
 * @Date: 2019/11/2 21:21
 * @Version 1.0
 */
public class User extends Thread {
    private final String myName;
    private final String myAddress;
    private final Gate gate;

    public User(String myName,String myAddress,Gate gate){
        this.myName = myName;
        this.myAddress = myAddress;
        this.gate = gate;
    }

    @Override
    public void run() {
        System.out.println(myName+" BEGIN ");
        while (true){
            //不断的通过这个门，也就是不断的使用这个资源。
            this.gate.pass(myName,myAddress);
        }
    }
}
